package com.vhall.component.service.room.assembler;

import com.vhall.component.entity.room.dto.RoomJoinsCacheDTO;
import com.vhall.component.entity.room.dto.RoomJoinsEntityDTO;
import com.vhall.component.entity.room.entity.RoomJoinsEntity;
import com.vhall.component.entity.room.vo.BannedKickedRspVO;
import org.mapstruct.Context;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 参会成员类实体对象间转换
 *
 * @author yuanzh
 */
@Mapper(componentModel = "spring")
public interface RoomJoinsAssembler {

    /**
     * 转换参会成员实体为响应对象
     *
     * @param entity 参会成员实体
     * @return 返回响应对象
     */
    BannedKickedRspVO joinsEntityToRspVo(RoomJoinsEntity entity);

    @Mapping(target = "roomId", expression = "java( roomId )")
    BannedKickedRspVO joinsEntityToRspVo2(RoomJoinsEntity entity, @Context String roomId);

    default List<BannedKickedRspVO> joinsEntitiesToRspVo2s(List<RoomJoinsEntity> entities, @Context String roomId) {
        if (entities == null) {
            return Collections.emptyList();
        }
        ArrayList<BannedKickedRspVO> list = new ArrayList<>(entities.size());
        for (RoomJoinsEntity entity : entities) {
            list.add(joinsEntityToRspVo2(entity, roomId));
        }
        return list;
    }

    /**
     * 转换参会成员列表为响应列表
     *
     * @param entities 参会成员列表
     * @return 返回响应列表
     */
    List<BannedKickedRspVO> joinsEntitiesToRspVos(List<RoomJoinsEntity> entities);

    /**
     * 转换参会信息为缓存对象
     *
     * @param entity 参会信息
     * @return 缓存对象
     */
    RoomJoinsCacheDTO joinEntityToCacheDTO(RoomJoinsEntity entity);

    /**
     * 转换参会信息实体为dto
     *
     * @param entity 参会信息
     * @return dto
     */
    RoomJoinsEntityDTO joinsEntityToDTO(RoomJoinsEntity entity);

    /**
     * 转换参会成员列表为dto列表
     *
     * @param entities 参会成员列表
     * @return dto列表
     */
    List<RoomJoinsEntityDTO> joinsEntitiesToDTOList(List<RoomJoinsEntity> entities);

}
